home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.sprintlink.net!news1!news
- From: koconnor@iquest.net (Kevin O'Connor)
- Subject: HELP: Pointer to member involving unions
- X-Nntp-Posting-Host: edge.iquest.net
- Message-ID: <DMw50M.zM@iquest.net>
- Sender: news@iquest.net (News Admin)
- Reply-To: koconnor@iquest.net
- Organization: Edge Software Services Inc.
- X-Newsreader: NeoLogic News for OS/2 [version: 4.5 Build YJ 048]
- Date: Fri, 16 Feb 1996 22:55:34 GMT
-
- Can anyone tell me why the last line of this example won't compile?
-
- struct Registers {
- union {
- short bc;
- struct {
- char b;
- char c;
- } bc8;
- };
- };
-
- class Proc : public Registers {
- static short Proc::*Test1;
- static char Proc::*Test2;
- };
-
- short Proc::*Proc::Test1 = &Proc::bc; // No error
- char Proc::*Proc::Test2 = &Proc::bc8.b; // Error: bc8 cannot be used w/o
- object
-
- I've tried this on a couple of compilers. My IBM C/Set++ 2.0 gives me the
- following errors:
-
- 16 |short Proc::*Proc::Test1 = &Proc::bc;
- cpptest.cpp(16:1) : error EDC3055: "short union {...}::*" cannot be converted
- to
- "short Proc::*".
- 17 |char Proc::*Proc::Test2 = &Proc::bc8.b;
- cpptest.cpp(17:1) : error EDC3078: Non-static member "Registers::union
- {...}::bc
- 8" must be associated with an object or a pointer to an object.
- cpptest.cpp(17:1) : error EDC3055: "char*" cannot be converted to "char
- Proc::*"
-
- My borland C++ 2.0 for OS/2 (equivalent to Borland C++ 3.1 for Windows) gives
- me the following:
-
- Error cpptest.cpp 17: Member bc8 cannot be used without an object
- *** 1 errors in Compile ***
-
- ------------------------------------------
- Kevin O'Connor
- Edge Software Services Inc.
- koconnor@iquest.net
- http://www.iquest.net/~koconnor/
- ------------------------------------------
-
-